package LeetCode.leetcode98;

public class Review2 {
    public boolean isValidBST(TreeNode root) {
        return isValidBST2(root, Long.MIN_VALUE, Long.MAX_VALUE);
    }
    public boolean isValidBST2(TreeNode root, long low, long high) {
        if (root == null) return true;
        if (root.val <= low || root.val >= high) return  false;
        return isValidBST2(root.left, low, root.val) && isValidBST2(root.right, root.val, high);

    }
}
